package com.chixing.ih.module.admin.mapper.Provider;

import org.apache.ibatis.jdbc.SQL;

public class AdminEchartsMapperProvider {

    public String transactionData(long mouth, long year) {
        return new SQL() {{
            SELECT("COUNT(1)*5");
            FROM("tbl_order");
            WHERE("date_format(order_end_time, '%c') = #{mouth} AND date_format(order_end_time, '%Y') = #{year}");
        }}.toString();
    }

    public String taskData(long mouth, long year) {
        return new SQL() {{
            SELECT("COUNT(1)");
            FROM("tbl_task");
            WHERE("date_format(create_time, '%c') = #{mouth} AND date_format(create_time, '%Y') = #{year}");
        }}.toString();
    }

    public String userData(int year) {
        return new SQL() {{
            SELECT("COUNT(1)");
            FROM("tbl_user");
            WHERE("role_id = 2 and date_format(create_time, '%Y') = #{year}");
        }}.toString();
    }

    public String vipData(int year) {
        return new SQL() {{
            SELECT("COUNT(1)");
            FROM("tbl_user");
            WHERE("role_id = 3 and date_format(create_time, '%Y') = #{year}");
        }}.toString();
    }

    public String cityData() {
        return new SQL() {{
            SELECT("region_city AS name,COUNT( region_city )*15 AS value");
            FROM("tbl_work");
            WHERE("is_deleted =0 AND region_city IS NOT NULL");
            GROUP_BY(" region_city");
        }}.toString();
    }


}
